Page({
    data: {},
    onLoad: function (e) {
        getApp().page.onLoad(this, e);
    },
    getUserInfo: function (o) {
        var n = this;
        getApp().core.login({
            success: function (e) {
                wx.setStorageSync('code', e.code)
            },
            fail: function (e) { }
        });
        wx.getUserProfile({
            desc: '展示用户信息', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
            success: (res) => {
                console.log('12331', res)
                n.unionLogin({
                    code: wx.getStorageSync('code'),
                    user_info: res.rawData,
                    encrypted_data: res.encryptedData,
                    iv: res.iv,
                    signature: res.signature,
                    recommend_id: wx.getStorageSync('recommender_id'),
                    source: wx.getStorageSync('source')
                });
            }
        })
    },
    myLogin: function () {
        var t = this;
        "my" === getApp().platform && my.getAuthCode({
            scopes: "auth_user",
            success: function (e) {
                t.unionLogin({
                    code: e.authCode,
                    recommend_id: wx.getStorageSync('recommender_id'),
                    source: wx.getStorageSync('source')
                });
            }
        });
    },
    unionLogin: function (e) {
        getApp().core.showLoading({
            title: "正在登录",
            mask: !0
        }), getApp().request({
            url: getApp().api.passport.login,
            method: "POST",
            data: e,
            success: function (e) {
                console.log('2222login')
                if (0 == e.code) {
                    getApp().setUser(e.data), getApp().core.setStorageSync(getApp().const.ACCESS_TOKEN, e.data.access_token),
                        getApp().trigger.run(getApp().trigger.events.login);
                    var t = getApp().core.getStorageSync(getApp().const.LOGIN_PRE_PAGE);
                    t && t.route ? getApp().core.redirectTo({
                        url: "/" + t.route + "?" + getApp().helper.objectToUrlParams(t.options)
                    }) : getApp().core.redirectTo({
                        url: "/pages/index/index"
                    });
                } else getApp().core.showModal({
                    title: "提示",
                    content: e.msg,
                    showCancel: !1
                });
            },
            complete: function () {
                getApp().core.hideLoading();
            }
        });
    }
});